#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int i1 = 1 ; 

int main()
{	
	int i2 = 1;
	char * st = (char *)malloc(20 * sizeof(char));
	strcpy(st,"abcd");
	pid_t pid = fork();
	
	if(pid == 0)	//子进程 
	{
		int i3 = 3;
		st[0] = '1';
		i1 = 2; i2= 2;
		printf("child : i1 = %d , i2 = %d , i3 = %d , st = %s\n",i1,i2,i3,st);
		exit(0);		
	}
	sleep(1);
	
	printf("main : i1 = %d , i2 = %d , st = %s\n",i1,i2,st);
	
	return 0; 
}
